var screenWidth = window.screen.width;
var screenHeight = window.screen.height
var oc = new ObjectControl()
var url = appconfig.protal;
var picker;
var id;

function getUrl() {
  var url = decodeURI(location.href) //获取url中"?"符后的字串
  var index = url.indexOf('?')
  url = url.substring(index, url.length)
  this.url = url
  var theRequest = new Object()
  if (url.indexOf('?') != -1) {
    var str = url.substr(1)
    strs = str.split('&')
    for (var i = 0; i < strs.length; i++) {
      theRequest[strs[i].split('=')[0]] = unescape(
        strs[i].split('=')[1]
      )
    }
  }
  return theRequest;
};
id = 'tableApp' + $.now();
$("body>div").attr("id", id);
id = "#" + id;
axios.defaults.timeout = 10000;
window.onpageshow = function (event) {
  if (event.persisted) {
    window.location.reload()
  }
}


function operate(item) {
  var type = item.action;
  var name = window.name.replace(/layui-layer-iframe/g, "")
  if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
    if (type == 'create' || type == 'modify') {
      vm.save()
    } else {
      if (vm[type]) {
        if (item.type && (item.type == 'sp' || item.type == 'bsh')) {
          vm.M_RETAIL_RCOPY(item)
        } else {
          vm[type]()
        }
      }
    }
  } else {
    return
  }
}

function operateMore(el, anchor) {
  mui('#' + el).popover('toggle', document.getElementById(anchor));
}


function operateMoreSubmit(item) {
  var item = JSON.parse(decodeURIComponent(item))
  vm.submitTtem(item)
  mui('#popover1').popover('toggle', document.getElementById("openPopover1"));
}
// window.parent.document.title = document.title;
layui.use('laypage', function () {
  var laypage = layui.laypage
  //执行一个laypage实例
  laypage.render({
    elem: 'test1',
    count: 50,
    layout: ['limit', 'skip', 'prev', 'next'],
    groups: 1,
    first: false,
    last: false,
    prev: '<em class="layui-icon layui-icon-left"></em>',
    next: '<em class="layui-icon layui-icon-right"></em>',
    jump: function () {}
  })
})
var vm = new Vue({
  el: id,
  data: {
    refParam: "",
    table_name: "",
    id: '',
    theRequest: {},
    table_button_list: [],
    query_column_list: [],
    ref_table_list: [],
    ref_record_id: ""
  },
  methods: {
    getSelectCallback: function (index, select_id, data, type) {
      console.log("我是回调的韩硕")
      console.log(index, select_id, data, type)
      var list = $("#layui-layer" + index, parent.document).find("iframe")[0].contentWindow.vm.$data.query_column_list;
      list.map(function (item) {
        if (item.id == select_id) {
          if (type == 'search') {
            item.data = data;
            item.default_value = data.desc;
          } else {
            vm.$set(item, 'value', data.dk)
            vm.$set(item.ref_value_info, 'value', data.pk)
          }
        }
      })
      console.log(list)
    },
    resetColumnList: function (type) {
      var selectParam = {};
      selectParam.table = this.theRequest.table_id;
      selectParam.tablename = this.table_name;
      selectParam.fixedcolumns = this.theRequest.fixedcolumns ? decodeURIComponent(this.theRequest.fixedcolumns) : "";
      if (this.theRequest.type == 'add') {
        selectParam.id = "-1";
      } else if (this.theRequest.type == 'modify') {
        selectParam.id = this.theRequest.modify_id;
      } else if (this.theRequest.type == 'ref_table') {
        selectParam.id = this.ref_record_id;
      }
      this.query_column_list.map(function (item) {
        if (type) {
          if (item.can_input == "Y") {
            if (item.ref_table_id) {
              selectParam[item.name] = item.value ? item.value : "";
              selectParam[item.ref_value_info.name] = item.ref_value_info.value ? item.ref_value_info.value : "";
            } else {
              selectParam[item.name] = item.value ? item.value : "";
            }
          }
        } else {
          if (item.ref_table_id) {
            selectParam[item.name] = item.value ? item.value : "";
            selectParam[item.ref_value_info.name] = item.ref_value_info.value ? item.ref_value_info.value : "";
          } else {
            selectParam[item.name] = item.value ? item.value : "";
          }
        }
      })
      return selectParam;
    },
    valid: function () {
      var list = this.query_column_list;
      for (var i = 0, len = list.length; i < len; i++) {
        if (list[i].is_nullable == "N" && !list[i].value) {
          mui.alert(list[i].show_name + '不能为空');
          return false
        }
      }
      return true
    },
    save: function () {
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        if (this.valid()) {
          this.saveDada()
        }
      }

    },
    saveDada: function () {
      var that = this;
      var param = {}
      if (this.theRequest.type == 'ref_table' && this.pdata) {
        param = Object.assign(param, this.pdata),
          param.inlineobj = this.resetColumnList(true)
      } else {
        param = {
          "nds.control.ejb.UserTransaction": "N",
          "masterobj": this.resetColumnList(true)
        }
      }
      console.log(param)
      mui.showLoading()
      oc.postRequire('get', url, param, that.id, "ObjectCreate", function (res) {
        if (res.status == 'SUCCESS') {
          that.id = res.id;
          setID(that.id);
          mui.hideLoading();
          if (that.theRequest.type == 'ref_table') {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭 
            window.parent.frameArray.pop();
            if (window.parent.frameArray.length == 0) {
              removeTableId();
            } else {
              var beforeIndex = parent.frameArray[parent.frameArray.length - 1];
              setTableId(beforeIndex)
            }
          } else {
            that.backgetData()
          }
        } else {
          mui.hideLoading()
          mui.alert(res.msg)
        }
      }, function () {
        mui.hideLoading();
        mui.alert('操作失败')
      })
    },
    voidItem: function () {
      var that = this;
      var param = {
        "command": this.table_name + "Void",
        "parsejson": "Y",
        "id": this.theRequest.modify_id,
        "table": this.theRequest.table_id,
        "tablename": this.table_name,
        "fixedcolumns": ""
      }
      oc.postRequire('get', url, param, that.id, "EjbHandler", function (res) {
        if (res.status == 'SUCCESS') {
          // that.backgetData()
          mui.alert("操作成功", function () {
            that.backgetData()
          })
        } else {
          mui.alert(res.msg)
        }
      })
    },
    void: function () {
      var that = this;
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        var btnArray = ['取消', '我已确认'];
        mui.confirm('确认作废?', "",
          btnArray,
          function (e) {
            if (e.index == 1) {
              that.voidItem();
            }
          })
      }
    },
    setOperatList: function () {
      var html = "";
      var moreHtml = "";
      var moreHtmlSub = "";
      console.log(this.theRequest)
      if (this.theRequest.type == 'search') {
        var btn = {
          action: "sure",
          name: "确定"
        }
        html += "<div class='operate-item'  onclick='operate(" + JSON.stringify(btn) + ")'>" +
          "<dl>" +
          "<dt><img src='../img/sure.png' /></dt>" +
          "<dd>确定</dd>" +
          "</dl>" +
          "</div>"
      } else {
        this.table_button_list.map(function (btn, index) {
          if (btn.action == 'add') return
          if (index < 4) {
            if (btn.action == 'submit') {
              html += "<div class='operate-item' id='openPopover1' onclick='operate(" + JSON.stringify(btn) + ")'>" +
                "<dl>" +
                "<dt><img src='../img/" + btn.action + ".png' /></dt>" +
                "<dd>" + btn.name + "</dd>" +
                "</dl>" +
                "</div>"
            } else {
              html += "<div class='operate-item'  onclick='operate(" + JSON.stringify(btn) + ")'>" +
                "<dl>" +
                "<dt><img src='../img/" + btn.action + ".png' /></dt>" +
                "<dd>" + btn.name + "</dd>" +
                "</dl>" +
                "</div>"
            }

          } else if (index >= 4) {
            moreHtml += '<li class = "mui-table-view-cell">' +
              '<a>' + btn.name + '</a>' +
              '</li>'
          }
        })
        if (this.table_button_list.length > 4) {
          html += "</div>" +
            "<div id='openPopover' class='operate-item' onclick='operateMore(\"popover\",\"openPopover\")'>" +
            "<dl>" +
            "<dt><img src='../img/more.png'></dt>" +
            "<dd>更多</dd>" +
            "</dl>" +
            "</div>"
        }
      }
      this.ref_table_list.map(function (btn) {
        moreHtmlSub += '<li class = "mui-table-view-cell" onclick="operateMoreSubmit(\'' + encodeURIComponent(JSON.stringify(btn)) + '\')">' +
          '<a>' + btn.name + '</a>' +
          '</li>'
      })
      $("#operate-list").html(html)
      $("#popover .mui-table-view").html(moreHtml)
      $("#popover1 .mui-table-view").html(moreHtmlSub)
    },
    deteleItem: function () {
      var that = this;
      var param = {
        "parsejson": "Y",
        "table": this.theRequest.table_id,
        "tablename": this.table_name,
        "command": this.table_name + "Delete",
        "id": this.theRequest.modify_id
      }
      oc.postRequire('get', url, param, that.id, "EjbHandler", function (res) {
        if (res.status == 'SUCCESS') {
          that.backgetData();
        } else {
          mui.alert(res.msg)
        }
      })
    },
    delete: function () {
      var name = window.name.replace(/layui-layer-iframe/g, "");
      var that = this;
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        var btnArray = ['取消', '我已确认'];
        mui.confirm('确认删除数据', "",
          btnArray,
          function (e) {
            if (e.index == 1) {
              that.deteleItem();
            }
          })
      }
    },
    submitTtem: function (item) {
      var can_modify = false;
      var that = this;
      this.table_button_list.map(function (item) {
        item.action == 'submit' && (can_modify = item.can_modify);
      })
      var btnArray = ['取消', '我已确认'];
      mui.confirm('确认提交?', "",
        btnArray,
        function (e) {
          if (e.index == 1) {
            if (can_modify) {
              var param = {
                "nds.control.ejb.UserTransaction": "N",
                addList: [],
                modifyList: [],
                deleteList: [],
                command: "ProcessObject",
                column_masks: item ? item.query_info.column_masks ? item.query_info.column_masks : "" : "",
                fixedColumns: item ? item.query_info.fixedcolumns ? item.query_info.fixedcolumns : "" : "",
                bestEffort: true,
                masterobj: that.resetColumnList(true),
                queryRequest: item ? item.query_info ? item.query_info : "" : "",
                submitAfterSave: "Y",
                table: item ? item.query_info.table ? item.query_info.table : "" : that.table_name,
              }
            } else {
              var param = {
                command: that.table_name + "Submit", //表名+Submit
                fixedcolumns: "", //固定值""
                id: that.theRequest.modify_id, //主表记录ID
                parsejson: "Y", //固定值：Y
                table: that.theRequest.table_id, //主表ID
                tablename: that.table_name //主表名称
              }
            }
            oc.postRequire('get', url, param, that.id, 'EjbHandler', function (res) {
              if (res.status == "SUCCESS") {
                mui.alert('提交成功', function () {
                  that.backgetData();
                })
              } else {
                mui.alert(res.msg)
              }
            })
          }
        })
    },
    M_RETAIL_RCOPY_item: function (item) {
      console.log(item)
      var can_modify = false;
      var that = this;
      var btnArray = ['取消', '我已确认'];
      mui.confirm('确认' + item.name + "?", "",
        btnArray,
        function (e) {
          if (e.index == 1) {
            var param = {
              "webaction": item.id,
              "objectid": that.theRequest.modify_id,
              "command": "ExecuteWebAction",
              "query": {
                "query": null,
                "selection": [],
                "table": that.theRequest.table_id,
                "id": that.theRequest.modify_id
              }
            }
            oc.postRequire('get', url, param, that.id, 'EjbHandler', function (res) {
              if (res.status == "SUCCESS") {
                mui.alert('操作成功', function () {
                  that.backgetData();
                })
              } else {
                mui.alert(res.msg)
              }
            })
          }
        })
    },
    backgetData: function (data) {
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
      parent.layer.close(index); //再执行关闭 
      window.parent.frameArray.pop();
      if (window.parent.frameArray.length == 0) {
        removeTableId();
        if (data) {
          parent.vm.$data.query_column_list = this.query_column_list;
          parent.vm.getTableData(this.query_column_list)
        } else {
          parent.vm.getTableData()
        }
      } else {
        var beforeIndex = parent.frameArray[parent.frameArray.length - 1];
        setTableId(beforeIndex)
        if (data) {
          $("#layui-layer" + beforeIndex, parent.document).find("iframe")[0].contentWindow.vm.$data.query_column_list = this.query_column_list;
          $("#layui-layer" + beforeIndex, parent.document).find("iframe")[0].contentWindow.vm.getTableData(this.query_column_list)
        } else {
          $("#layui-layer" + beforeIndex, parent.document).find("iframe")[0].contentWindow.vm.getTableData()
        }
      }

    },
    unsubmitItem: function () {
      var that = this;
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
      var param = {
        "command": this.table_name + "Unsubmit", //表名+Submit
        parsejson: "Y", //固定值：Y
        "id": this.theRequest.modify_id, //主表记录ID
        "table": this.theRequest.table_id, //主表ID
        "tablename": this.table_name, //主表名称
        "fixedcolumns": "", //固定值""
      }
      oc.postRequire('get', url, param, that.id, 'EjbHandler', function (res) {
        if (res.status == 'SUCCESS') {
          mui.alert("取消提交成功", function () {
            that.backgetData()
          })
        } else {
          mui.alert(res.msg)
        }
      })
    },
    unvoidItem: function () {
      var that = this;
      var param = {
        "command": this.table_name + "Unvoid", //表名+Submit
        parsejson: "Y", //固定值：Y
        "id": this.theRequest.modify_id, //主表记录ID
        "table": this.theRequest.table_id, //主表ID
        "tablename": this.table_name, //主表名称
        "fixedcolumns": "" //固定值""
      }
      oc.postRequire('get', url, param, that.id, 'EjbHandler', function (res) {
        if (res.status == 'SUCCESS') {
          mui.alert("取消作废成功", function () {
            that.backgetData()
          })
        } else {
          mui.alert(res.msg)
        }
      })
    },
    unsubmit: function () {
      var that = this;
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        var btnArray = ['取消', '我已确认'];
        mui.confirm('确认取消提交?', "",
          btnArray,
          function (e) {
            if (e.index == 1) {
              that.unsubmitItem();
            }
          })
      }
    },
    unvoid: function () {
      var that = this;
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        var btnArray = ['取消', '我已确认'];
        mui.confirm('确认取消作废?', "",
          btnArray,
          function (e) {
            if (e.index == 1) {
              that.unvoidItem();
            }
          })
      }
    },
    M_RETAIL_RCOPY: function (item) {
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        this.M_RETAIL_RCOPY_item(item);
      }
    },
    submit: function () {
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        if (this.ref_table_list.length > 0) {
          mui('#popover1').popover('toggle', document.getElementById("openPopover1"));
        } else {
          this.submitTtem()
        }
      }
      // console.log($(window.parent.document).contents().find("iframe")[0].contentWindow.vm.$data)
    },
    sure: function () {
      var name = window.name.replace(/layui-layer-iframe/g, "");
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem('tableId'))) {
        this.backgetData(this.query_column_list)
      }
      // console.log($(window.parent.document).contents().find("iframe")[0].contentWindow.vm.$data)
    },
    getRefTable: function () {
      var that = this;
      var param = this.refParam;
      mui.showLoading();
      oc.postRequire('get', url, param, that.id, 'InlineTable', function (
        res
      ) {
        mui.hideLoading();
        if (res.status == 'SUCCESS') {
          that.id = res.id;
          setID(that.id);
          res.data.button_list && (that.table_button_list = that.table_button_list.concat(res.data.button_list));
          res.data.column_list && (that.query_column_list = that.query_column_list.concat(res.data.column_list));
          res.data.record_id && (that.ref_record_id = res.data.record_id);
          res.data.name && (that.table_name = res.data.name);
          that.setOperatList();
        } else if (res.status == "FAILED" && res.error_code == "-2") {
          that.login(that.getRefTable);
        } else {
          mui.toast('获取数据失败')
        }
      })
    },
    selectThis: function (type, item) {
      var that = this;
      document.activeElement.blur();
      var name = window.name.replace(/layui-layer-iframe/g, "")
      if (item.can_input == "N") return;
      if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem(
          'tableId'))) {
        var content = "";
        if (type == 'ref_table') {
          var param = {
            "nds.control.ejb.UserTransaction": "N",
            "masterobj": this.resetColumnList(true)
          }
          if (item.type == 2) {
            content = './table.html?type=' + type + '&parent_table_id=' + that.theRequest.table_id + '&parent_record_id=' + that.theRequest.modify_id +
              '&child_table_id=' + item.table_id + '&fixedcolumns=' + encodeURIComponent(item.fixedColumns) + '&table_id=' + item.table_id
          } else {
            content = './form.html?type=' + type + '&parent_table_id=' + that.theRequest.table_id + '&parent_record_id=' + that.theRequest.modify_id +
              '&child_table_id=' + item.table_id + '&fixedcolumns=' + encodeURIComponent(item.fixedColumns) + '&table_id=' + item.table_id +
              '&pdata=' + encodeURIComponent(JSON.stringify(param))
          }
        } else {
          content = './table.html?type=' + type + '&table_id=' + item.ref_table_id + '&select_id=' + item.id;
        }
        layui.use('layer', function () {
          var index = parent.layer.open({
            title: type == 'ref_table' ? '查看 - ' + item.name : '筛选 - ' + item.show_name,
            type: 2,
            area: [screenWidth + 'px', "100%"],
            content: content,
            maxmin: false,
            zIndex: parent.layer.zIndex,
            success: function (layero) {
              parent.layer.setTop(layero);
              setTableId(index)
              window.parent.frameArray.push(index)
            },
            cancel: function (index, layero) {
              var name = window.name.replace(/layui-layer-iframe/g, "");
              setTableId(name)
              window.parent.frameArray.pop();
            },
            end: function () {
              var list = JSON.parse(JSON.stringify(that.query_column_list));
              that.query_column_list.map(function (item) {
                vm.$set(item, "value", "");
              })
              list.map(function (item, index) {
                that.query_column_list[index].value = item.value;
              })
            }
          });
          parent.layer.full(index);
          parent.layer.iframeAuto(index)
        })
      }
    },
    resetTime: function (time, item) {
      if (item.value_type == 3) {
        return time.replace(/-/g, '')
      } else if (item.value_type == 1) {
        return time
      }
    },
    showSelect(item) {
      var items = item.items;
      var that = this;
      if (item.can_input == 'N') return;
      picker = picker || new mui.PopPicker();
      var array = [];
      items.map(function (ele) {
        array.push({
          value: ele.value,
          text: ele.name == 'all' ? "全部" : ele.name
        })
      })
      picker.setData(array);
      picker.show(function (selectItems) {
        if (that.theRequest.type == 'search') {
          item.default_value = selectItems[0].value;
        } else {
          item.value = selectItems[0].value;
        }
      })
      // picker.hide(function(){
      //   picker.dispose()
      // })
    },
    selectActivityTime: function (type, item) {

      document.activeElement.blur();
      var _this = this;
      var dataType = "";
      if (item.can_input == "N") return;
      if (item.value_type == 1) {

      } else if (item.value_type == 3) {
        dataType = "date"
      }
      if (!type || type == 'start') {
        var dtPicker = new mui.DtPicker({
          "type": dataType
        });
      } else {
        var beginDate = item.start_time && new Date(item.start_time.replace(/-/g, '/')); //设置开始日期 ;
        var dtPicker = new mui.DtPicker({
          "type": dataType,
          beginDate: beginDate
        });
      }
      dtPicker.show(function (selectItems) {
        if (!type) {
          vm.$set(item, 'value', selectItems.text)
        } else if (type == 'start') {
          vm.$set(item, 'start_time', selectItems.text)
          // vm.$set(item, 'end_time', '')
        } else {
          vm.$set(item, 'end_time', selectItems.text)
          // var d1 = new Date(item.start_time.replace(/\-/g, "\/"));
          // var d2 = new Date(item.end_time.replace(/\-/g, "\/"));
          // if (item.start_time != "" && item.end_time != "" && d1 >= d2) {
          //   dtPicker.hide()
          //   mui.alert("开始时间不能大于结束时间！");
          //   item.end_time = ""
          // }
        }
      })
    },
    // operate: function (type) {
    //   var name = window.name.replace(/layui-layer-iframe/g, "")
    //   if (!sessionStorage.getItem('tableId') || (name == sessionStorage.getItem(
    //       'tableId'))) {
    //     this[type] && this[type]()
    //   } else {
    //     return
    //   }
    // },
    refresh: function () {
      window.location.reload();
    },
    getUrl: function () {
      var url = decodeURI(location.href) //获取url中"?"符后的字串
      var index = url.indexOf('?')
      url = url.substring(index, url.length)
      this.url = url
      var theRequest = new Object()
      if (url.indexOf('?') != -1) {
        var str = url.substr(1)
        strs = str.split('&')
        for (var i = 0; i < strs.length; i++) {
          theRequest[strs[i].split('=')[0]] = unescape(
            strs[i].split('=')[1]
          )
        }
      }
      this.theRequest = theRequest;
    },
    login: function () {
      var that = this
      if (!sessionStorage.getItem('em') || !sessionStorage.getItem('pwd')) {
        mui.alert('获取登陆信息失败');
        return
      }
      var param = {
        email: sessionStorage.getItem('em'),
        pwd: sessionStorage.getItem('pwd')
      }
      mui.showLoading();
      oc.postRequire('get', url, param, '', 'Login', function (res) {
        mui.hideLoading();
        if (res.status == 'SUCCESS') {
          that.id = res.id
          setID(that.id);
          if (that.theRequest.type == 'search') {
            that.getTable()
          } else if (that.theRequest.type == 'add') {
            that.getTableInfo()
          } else if (that.theRequest.type == 'modify') {
            that.getTableInfo(that.theRequest.modify_id)
          }
        }
      })
    },
    getTableInfo: function (id) {
      var that = this;
      var param = {
        "table_id": this.theRequest.table_id,
        "record_id": id ? id : "-1",
        "action": "",
        "input": true
      }
      oc.postRequire('get', url, param, that.id, 'TableInfo', function (res) {
        if (res.status == 'SUCCESS') {
          that.id = res.id
          setID(that.id)
          that.table_button_list = that.table_button_list.concat(res.data.button_list);
          that.query_column_list = res.data.column_list;
          that.ref_table_list = res.data.ref_table_list ? res.data.ref_table_list : "";
          that.query_column_list.map(function (item) {
            !item.value && vm.$set(item, "value", "")
          })
          that.table_name = res.data.name;
          that.show_name = res.data.show_name;
          that.setOperatList()
        } else {
          if (res.error_code == '-2') {
            that.login()
          } else {
            mui.alert(res.msg)
          }
        }
      })
    },
    getTable: function () {
      var that = this
      var param = {
        table_id: this.theRequest.table_id
      }
      mui.showLoading()
      oc.postRequire('get', url, param, that.id, 'TableList', function (
        res
      ) {
        mui.hideLoading()
        if (res.status == 'SUCCESS') {
          that.id = res.id;
          setID(that.id);
          that.table_button_list = that.table_button_list.concat(res.data.table_button_list);
          that.query_column_list = res.data.query_column_list;
          that.table_name = res.data.name;
          that.query_column_list.map(function (item) {
            item.name = that.table_name + "." + item.name
          })
          that.setOperatList()
        } else {
          if (res.error_code == '-2') {
            that.login()
          }
        }
      })
    }
  },
  created() {
    this.getUrl();
    var ID = sessionStorage.getItem('ID')
    if (ID) {
      this.id = ID;
      var type = this.theRequest.type;
      switch (type) {
        case 'search':
          this.getTable();
          break;
        case 'add':
          this.getTableInfo();
          break;
        case 'modify':
          this.getTableInfo(this.theRequest.modify_id);
          break;
        case 'ref_table':
          this.refParam = {
            child_table_id: this.theRequest.child_table_id,
            fixedcolumns: decodeURIComponent(this.theRequest.fixedcolumns),
            parent_record_id: this.theRequest.parent_record_id,
            parent_table_id: this.theRequest.parent_table_id
          }
          this.pdata = JSON.parse(decodeURIComponent(this.theRequest.pdata))
          console.log(this.pdata)
          this.getRefTable();
      }
    } else {
      this.login()
    }
  }
})